package edu.sctu.xiangkun.day201506.day20150615.textone;

import java.io.*;

/**
 * Created by user04 on 2015/6/15.
 */
public class FileReaderOrWriterDemo {

    public void getContent() throws IOException {
        int count=0;
        FileReader fileReader;
        FileWriter fileWriter;
        File file = new File("D:/1.txt");
        File file1 = new File("D://11.txt");
    try{
        fileReader = new FileReader(file);
        fileWriter = new FileWriter(file1);
        try{
            while((count=fileReader.read()) != -1){
                fileWriter.write(count);
                System.out.println((char) count);
            }
            while(fileReader.ready()){
                int a = fileReader.read();
                fileWriter.write(a);
                System.out.print((char) a);
            }
            System.out.println("\n文件创建成功！");
        }catch(IOException e){
            e.printStackTrace();
        }
        try{
            fileReader.close();
            fileWriter.close();
        }catch (IOException e){
            e.printStackTrace();
        }
    }catch(FileNotFoundException e){
        e.printStackTrace();
    }
    }
}
